package file.listener;

import file.FileFrame;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

/**
 * @Author: zou
 * @email: 704572528@qq.com
 * @Date: 2020/10/30 13:05
 */
public class MenuListener extends FileFrameAbstract implements MouseListener {

    public MenuListener(FileFrame fileFrame) {
        super(fileFrame);
    }

    @Override
    public void mouseClicked(MouseEvent e) {

    }

    @Override
    public void mousePressed(MouseEvent e) {

        triggerEvent(e);
    }


    private void triggerEvent(MouseEvent event) { //处理事件

        if (event.isPopupTrigger()){

            fileFrame.getMenu().show(event.getComponent(), event.getX(), event.getY()); //显示菜单

        }
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        triggerEvent(e);
    }

    @Override
    public void mouseEntered(MouseEvent e) {

    }

    @Override
    public void mouseExited(MouseEvent e) {

    }
}
